function f(c) {

    c.reset();

    c.defineController({
        path: "/test",
        handle: function (p) {
            var resp = p.response;
            resp.setHeader('Access-Control-Allow-Origin', '*');
            resp.setHeader('Content-Type', 'text/event-stream');
            var writer = resp.writer;

            var d = p.async();

            var task = timer.interval(function () {
                try {
                    if (!resp.writer.checkError()) {
                        writer.write('data:hello\n\n');
                        // writer.flush();
                        log.info('输出成功')
                    } else {
                        log.info('关闭通道');
                        task.cancel(true);
                        d.result = null;
                    }
                } catch (e) {
                    log.info('关闭通道');
                    task.cancel(true);
                    d.errorResult = null;
                }

            }, 1000);

            //如果立刻返回服务端就会立刻关闭通道  需要使用DeferredResult或Callable进行改造

            return d;
        }

    });

}